<template>
  <div>
    <h2 class="van-doc-block__title">加油卡详情</h2>
    <div>
      <van-card :key="data.gascardId" :title="'加油卡编号:' + data.gascardNo">
        <template #price>
          <div>余额：￥{{data.balance}}</div>
          <div>每月充值金额：￥{{data.ykczPrice}}</div>
        </template>
        <template #desc>
          <div>加油卡状态：{{gascardStatus[data.gascardStatus]}}</div>
          <div v-if="data.gascardStatus==3">损坏原因：{{data.statusNote}}</div>
          <div>车牌号：{{data.carPlate}}</div>
          <div>车主：{{data.ownerName}}</div>
          <div>企业名称：{{data.corpName}}</div>
        </template>
      </van-card>
    </div>


  </div>
</template>

<script>
  import {Toast} from "vant";

  export default {
    name: "enterpriseCarCardDetail",
    data() {
      return {
        gascardId: '',
        gascardStatus: ['未分配', '已分配到公司', '已分配到车辆', '已损坏'],
        data: {}
      };
    },
    created() {
      this.gascardId = this.$route.query.gascardId;
      this.onLoad();
    },
    methods: {
      onLoad() {
        // 异步更新数据
        let data = {
          gascardId: this.gascardId
        };
        this.$Api.get("/api/cqhGascard/gascrdInfo", data).then(res => {
          if (res.data.code == 200) {
            this.data = res.data.data;
            this.data.carPlate = res.data.data.cqhCar.carPlate;
            this.data.ownerName = res.data.data.cqhCar.ownerName;
            this.data.corpName = res.data.data.cqhCorp.corpName;
          } else {
            Toast(res.data.message);
          }
        }).catch(err => {
        });
      }
    }
  };
</script>

<style lang="scss" scoped>
  .van-doc-block__title {
    margin: 0;
    padding: 24px 16px 16px;
    color: #09f;
    font-weight: normal;
    font-size: 16px;
    line-height: 16px;
    text-align: center;
    border-bottom: 1px solid #09f;
  }

  .van-card {
    background-color: #fff;
  }

  .van-form,
  .van-card {
    line-height: 1.5;
    border-top: 8px solid #f5f5f5;
  }

  .van-card__bottom {
    margin-top: 10px;
  }
</style>
